<?php
namespace app\admin\validate;

use think\Validate;

class User extends Validate
{
    protected $rule = [
        'user_name'  =>  'require|max:30|unique:user',
        'user_password'  =>  'require|max:60|min:5',
        'user_type' =>  'require|in:0,1',
        'active_status' =>  'require|in:0,1',
    ];
    
    protected $message  =   [
        'user_name.require' => '用户名不能为空',
        'user_name.max'     => '用户名不能超过30个字符',
        'user_name.unique'  => '用户名不允许重复',
        'user_password.require' => '用户密码不能为空',
        'user_password.max' => '密码长度不能超过60个字符',
        'user_password.min' => '密码长度不能少于5个字符',
        'user_type.require' => '用户类型不能为空',
        'user_type.in'  => '用户类型必须为普通用户或者管理员',
        'active_status' => '用户激活状态不能为空',
        'active_status' => '用户激活状态必须为已激活或者未激活',
    ];
    
    protected $scene = [
        'edit' => ['userName'=>'require|max:30','user_password' => 'require|max:60|min:5','user_type' => 'require|in:0,1', 'active_status' =>  'require|in:0,1'],
    ];
}
